<?php
$this->breadcrumbs()->addPage('Consulta', 'consultar');
echo $this->breadcrumbs()->render();

echo $this->render('snippets/abasConsulta.phtml');

echo $this->pagenav()->openList();
echo $this->pagenav()->defaultHelperLinks();
echo $this->pagenav()->closeList();
?>

<div id="article">
    <form action="<?php echo $this->simpleUrl('resultados') ?>" method="post">
        <?php
        echo $this->fieldList()->open();
        echo $this->fieldList()->textbox('Número', 'numero', null, array('length' => 20));
        echo $this->fieldList()->select('Tipo de Processo', 'tipoprocesso', $this->tiposProcesso);
        echo $this->fieldList()->select('Assunto', 'assunto', array());
        echo $this->protocoloSelect('Proprietário', 'proprietario', $this->listaProtocolos);
        echo $this->protocoloSelect('Local Atual', 'protocolo', $this->listaProtocolos);
        echo $this->fieldList()->textbox('Envolvido', 'envolvido', null, array('length' => 60));
        echo $this->fieldList()->textbox('CPF/CNPJ', 'cpf');
        echo $this->fieldList()->textbox('Observação', 'observacao', null, array('length' => 60));
        //echo $this->fieldList()->textbox('Data', 'data', null, array('class' => 'mascaraData'));
		echo $this->fieldList()->textbox('Data Inicio', 'dataInicio', null, array('class' => 'mascaraData'));
		echo $this->fieldList()->textbox('Data Fim', 'dataFim', null, array('class' => 'mascaraData'));
        echo $this->fieldList()->textbox('Corpo', 'corpo');
        echo $this->fieldList()->select('Status', 'status', $this->listaStatus);
        echo $this->fieldList()->checkbox('Possui Volume', 'volume');
        echo $this->fieldList()->close();

        echo $this->buttonlist()->open();
        echo $this->buttonlist()->button('Buscar');
        echo $this->buttonlist()->resetbutton();
        echo $this->buttonlist()->close(true);
        ?>
    </form>

    <?php
    $js = 'jQuery(document).ready(function() {
               $("#tipoprocesso").change(function() {
                   $.ajax({
                       dataType: "json",
                       url:"' . $this->simpleUrl('assuntos-ajax', 'tiposprocesso') . '/id/" + $(this).val(),
                       success: function(data) {
                           $("#assunto option").remove();
                           $(data).each(function(i, value) {
                               $("#assunto").append("<option value=\"" + value.id + "\">" + value.name + "</option>");
                           });
                       },
                       error: function(data) {
                           $("#assunto option").remove();
                       }
                   });
               });
           });';
    $this->headScript()->appendScript($js);
    ?>
</div>